%
% Author: Vasyl Mykhalchuk
% 03/02/2012
%
function [ ] = cloth( )
addpath(genpath('../io'));
addpath(genpath('../obj-tools'));
addpath(genpath('../export'));
addpath(genpath('../neighborhood'));
%{
[verts, topology] = read_wobj('SimpleCloth.obj');
frames = load('Cloth100Verts.mat');
frames = frames.Cloth;
save('SimpleCloth.mat', 'frames', 'topology');

[verts, topology] = read_wobj('ComplexCloth.obj');
frames = load('ComplexCloth.txt');
save('ComplexCloth.mat', 'frames', 'topology');
%}

simpleCloth = load('ComplexCloth.mat');
clothDistMatrix = load('ComplexClothDistMatrix.mat');
distMatrix = clothDistMatrix.distMatrix;

vert = simpleCloth.frames(1, :);
vert = toMatrix(vert);
nV = size( vert, 1);
vertId = 31;
epsilon = 25.0;
colorList = zeros(nV, 3);

%{
colorList(:,:) = 100; 
for i = 1:nV
    if ( distMatrix(vertId, i) < epsilon)
        colorList(i, :) = 200;
    end % if
end % for
%}

%{
field = rand(nV,2);
indeces = (1:nV)';
field(:,2) = indeces;
field = sortrows(field);
colorList = rainbow( nV );
colorList(:,4) = field(:,2);
colorList = sortrows(colorList, 4);
%}

exportPLY('complex-cloth.ply', vert, colorList(:,1:3), simpleCloth.topology);


end % function cloth

